# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=casync
pkgver=2.r267.g0efa7ab
# NOTE: we lock a recent commit because there has not been a release in a long
# time and the amount of patches to backport would be immense:
# https://github.com/systemd/casync/issues/99
# https://github.com/systemd/casync/issues/212
# https://github.com/systemd/casync/issues/253
_commit=0efa7abffe5fffbde8c457d3c8fafbdde0bb6e4f
pkgrel=2
pkgdesc="Content-Addressable Data Synchronization Tool"
arch=(loong64 x86_64)
url="https://github.com/systemd/casync/"
license=(LGPL2.1)
depends=(fuse gcc-libs glibc openssl zlib)
makedepends=(acl curl fuse2 git meson python-sphinx systemd xz zstd)
checkdepends=(gzip nbd python rsync)
options=(debug)
source=($pkgname::git+$url#commit=$_commit)
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/v//g;s/-/./g'
}

build() {
  arch-meson build $pkgname -Dselinux=false
  meson compile -C build
}

check() {
  meson test -C build
}

package() {
  depends+=(
    curl libcurl.so
    acl libacl.so
    systemd-libs libudev.so
    xz liblzma.so
    zstd libzstd.so
  )
  meson install -C build --destdir "$pkgdir"
}
